package com.mgg.goods.service.seckill.impl;

import java.util.List;
import java.util.Map;

import com.mgg.common.dao.DaoSupport;
import com.mgg.goods.service.seckill.SecKillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("secKillService")
public class SecKillServiceImpl implements SecKillService{

	@Autowired
	private DaoSupport dao;

	@Override
	public Object listTodayActivity() {
		return dao.findForList("SeckillMapper.listTodayActivity", null);
	}

	@Override
	public Object listSecKillGoods(String seckillId) {
		List<Map<String,Object>> list= dao.findForList("SeckillMapper.listSecKillGoods", seckillId);
		for (Map<String,Object> goods : list) {			
			goods.put("goodsPic", goods.get("goodsPic").toString().split(",")[0]);
			goods.put("goodsNum", Integer.parseInt(goods.get("goodsNum").toString()) + Integer.parseInt(goods.get("fakeNum").toString()));
		}
		return list;
	}

}
